<?php
//进程worker管理器
//这个是server.class.php的替换版本信息
class Worker{

    /**
     * 配置pid文件相关信息
     * @var string
     * User kuoqi
     * Datetime 2022/3/27 11:25
     * Remark
     */
    protected $pidfile = '';

    /**
     * 进程uid
     * @var int
     * User kuoqi
     * Datetime 2022/3/27 11:26
     * Remark
     */
    protected $uid        = 80;

    /**
     * 进程GID
     * @var int
     * User kuoqi
     * Datetime 2022/3/27 11:26
     * Remark
     */
    protected $gid        = 80;

    //主进程
    public function main(){}

    //run运行进程
    public function run(){}

    //开始进程
    public function start(){}

    //停止进程
    public function stop(){}

    //重启进程
    public function reload(){}

    /**
     * 信号进程
     * User kuoqi
     * Datetime 2022/3/27 11:28
     * Remark
     */
    public function signal(){
        pcntl_signal(SIGHUP,  function($signo) /*use ()*/{
            //echo "\n This signal is called. [$signo] \n";
            printf("The process has been reload.\n");
            Signal::set($signo);
        });
    }

    //帮助方法
    public function help(){}

    /**
     * 运行初始化
     * User kuoqi
     * Datetime 2022/3/27 11:28
     * Remark
     */
    public function runAll(){
        //配置pid文件信息
        $this->pidfile = '/var/run/'.basename(get_called_class(), '.php').'.pid';
        //监听信号
        $this->signal();
    }


}